#ifndef CVMANAGER_H
#define CVMANAGER_H

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <QImage>

using namespace cv;

namespace controllers {

    #define FEATURE_MATCHING_THRESHOLD 0.1

    class CVManager
    {
    public:
        CVManager();

        static QImage iplImageToQImage(const IplImage *iplImage);
        static QImage iplImageToQImage(const IplImage *iplImage, QSize size);
        static QImage matToQImage(const Mat &matImage);
        static QImage matToQImage(const Mat &matImage, QSize size);
        static QImage matToQImage(const Mat &matImage, QSize size, int gray);
        static Mat    qImageMatTo(const QImage &qImage);
        //QImage iplImageToQImage(QSize sizeLabelArea, const IplImage *iplImage);

        // Sharpens an image pixels with its neighboring pixels (3x3) using a Laplacian kernel
        /***
         *  0 -1  0
         * -1  5 -1
         *  0 -1  0
         */
        static void sharpen2D(const Mat &image, Mat &result);

        // Computes the Canny edges of an input image
        static void computeCanny(Mat& img, Mat& out);

        // Compute the floating point Laplacian and yield a result in 8-bit image
        // A scale of zero corresponds to gray level 128
        // If no scale is provided, then the max value will be
        // scaled to intensity 255
        static void computeLaplacian(const cv::Mat& image, Mat& result, int aperture = 5, double scale = -1.0);

        // Add a watermark to an image
        static void watermarkImage(Mat &matImage, Mat& watermarkImg, int x, int y);

        // Search for image1 into image2 by using a feature detection algorithm (SURF)
        // Salient points are detected and mapped between the two images
        // One the mapping is successful image one is found using homography
        static Mat findFeatures(Mat image1, Mat image2);
    };
}
#endif // CVMANAGER_H
